package com.ansion.log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Locale;

/**
 * @author john on 2020/11/8.
 * @version 1.0
 * @desc jvm log实现
 */
public class JvmLogger extends Logger{

    @Override
    public boolean showLog(int level, String tag) {
        return level >= logLevel;
    }

    @Override
    public void log(Throwable callerStack,int callerStackIndex, int level, @NonNull String tag,
                    @Nullable Throwable tr, @Nullable String msg, Object... args) {
        if (msg != null && args != null && args.length > 0) {
            msg = String.format(Locale.US, msg, args);
        }
        if (msg != null) {
            System.out.println("[" + tag + "] " + msg);
        }
        if (tr != null) {
            tr.printStackTrace();
        }
    }
}
